package action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import dao.BoardDao;
import dao.impl.BoardDaoImpl;
import domain.Board;

public class InputBoardAction extends Action
{

    public InputBoardAction()
    {
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws Exception
    {	
    	System.out.println("in action");
	    	Board board=(Board)form;
	    	System.out.println(board.getName());
	    	if(board==null) board=new Board("xp");
	    	BoardDao boardDao=new BoardDaoImpl();
    	boardDao.save(board);
//    	List<Board> list=boardDao.list();
//    	request.setAttribute("boardList", list);
    	String path = request.getContextPath();
    	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    	ActionForward actionForward = new ActionForward(basePath+"forum/forum.jsp",true);
		return actionForward;
//    	System.out.println("before forward");
//    	return mapping.findForward("forum");
    	
    }
}
